<template>
  <div v-loading="loading">
    <Detail :detailForm="detailForm" @editHandle="editHandle"></Detail>
  </div>
</template>

<script setup>
import tablePaging from '@/views/common/component/table-paging'
import Detail from  '@/views/common/component/detail'
import { onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
import {useRoute} from 'vue-router/dist/vue-router'
import {getOfflineDetail} from '@/api/resource/offline'
const router = useRouter()
const route = useRoute()
const loading = ref(false)
const detailForm = reactive({
  column:[
    {
      name:'名称',
      code: 'name',
      span: 6
    },
    {
      name:'课程类型',
      code: 'courseTypeName',
      span: 6
    },
    {
      name:'老师',
      span: 6,
      code: 'teacherName',
    },
    {
      isSpace: true,
      span: 6
    },
    {
      name:'开始时间',
      code: 'startTime',
      span: 6,
    },
    {
      name:'结束时间',
      code: 'endTime',
      span: 6,
    },
    {
      name:'资料',
      code: 'docName',
      span: 6
    },
    {
      isSpace: true,
      span: 6
    },
    {
      name:'题库',
      code: 'bankName',
      span: 6
    },
    {
      name:'状态',
      code: 'publishedFlag',
      span: 6,
      formatter: (row)=>{
        return row.publishedFlag == 1? '上架' : '下架'
      }
    },
    {
      name:'排序',
      code: 'orderNum',
      span: 6
    },
    {
      isSpace: true,
      span: 6
    },
    {
      name:'说明',
      code: 'remark',
      span: 6
    },
  ],
  data: {},
  hasEdit: true
})
const initInfo = () => {
  loading.value = true
  getOfflineDetail(route.query.id || '').then((res) => {
    detailForm.data = res.data
    loading.value = false
  })
}
const editHandle = () => {
  router.push({
    path: '/modules/resource/offline/add',
    query: { id: route.query.id, type: 'edit' }
  })
}

onMounted(() => {
  initInfo()
})
</script>

<style></style>
